import matplotlib.pyplot as plt # 调用matplotlib绘图库
plt.rcParams['font.sans-serif'] = ['simHei'] # 载入字体
import cv2

def pshow(words,picture):
    plt.imshow(picture[:,:,::-1])   # 将读取的图片以RGB转换为BGR
    plt.title(words), plt.xticks([]), plt.yticks([])
    plt.show() # 显示图片

img=cv2.imread('img/111.jpg')
pshow('原图',img)
gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
cv2.imwrite('img/gray111.jpg',gray)
g2=cv2.imread('img/gray111.jpg')
pshow('灰度图',g2)